// 升级状态枚举
enum OtaUpgradeStatus {
  started, // 开始升级
  startDownloading, // 开始下载固件
  downloadingFirmware, // 固件下载中
  downloadFailed, // 下载失败
  downloadSuccess, // 下载成功
  idle, // 空闲
  busy, // 忙碌
  openFile, // 打开文件
  openFileFailed, // 打开文件失败
  openFileSuccess, // 打开文件成功
  readFile, // 读取文件
  readFileFailed, // 读取文件失败
  readFileSuccess, // 读取文件成功
  writeFile, // 写入文件
  writeFileFailed, // 写入文件失败
  writeFileSuccess, // 写入文件成功
  closeFileSuccess, // 关闭文件成功
  closeFileFailed, // 关闭文件失败
  preparingTransfer, // 准备传输
  transferring, // 固件传输中
  transferPaused, // 传输暂停
  transferFailed, // 传输失败
  transferSuccess, // 传输成功
  verifyFile, // 验证文件
  verifyFileFailed, // 验证文件失败
  verifyFileSuccess, // 验证文件成功
  waitingUserAction, // 等待用户操作
  upgrading, // 设备升级中
  upgradeSuccess, // 升级成功
  upgradeFailed, // 升级失败
  cancelled; // 已取消

  String get name {
    switch (this) {
      case OtaUpgradeStatus.started:
        return "开始升级";
      case OtaUpgradeStatus.startDownloading:
        return "开始下载固件";
      case OtaUpgradeStatus.downloadingFirmware:
        return "固件下载中";
      case OtaUpgradeStatus.downloadFailed:
        return "下载失败";
      case OtaUpgradeStatus.downloadSuccess:
        return "下载成功";
      case OtaUpgradeStatus.idle:
        return "空闲";
      case OtaUpgradeStatus.busy:
        return "忙碌";
      case OtaUpgradeStatus.openFile:
        return "打开文件";
      case OtaUpgradeStatus.openFileFailed:
        return "打开文件失败";
      case OtaUpgradeStatus.openFileSuccess:
        return "打开文件成功";
      case OtaUpgradeStatus.readFile:
        return "读取文件";
      case OtaUpgradeStatus.verifyFile:
        return "验证文件";
      case OtaUpgradeStatus.verifyFileFailed:
        return "验证文件失败";
      case OtaUpgradeStatus.verifyFileSuccess:
        return "验证文件成功";
      case OtaUpgradeStatus.readFileFailed:
        return "读取文件失败";
      case OtaUpgradeStatus.readFileSuccess:
        return "读取文件成功";
      case OtaUpgradeStatus.writeFile:
        return "写入文件";
      case OtaUpgradeStatus.writeFileFailed:
        return "写入文件失败";
      case OtaUpgradeStatus.writeFileSuccess:
        return "写入文件成功";
      case OtaUpgradeStatus.closeFileSuccess:
        return "关闭文件成功";
      case OtaUpgradeStatus.closeFileFailed:
        return "关闭文件失败";
      case OtaUpgradeStatus.preparingTransfer:
        return "准备传输";
      case OtaUpgradeStatus.transferring:
        return "固件传输中";
      case OtaUpgradeStatus.transferPaused:
        return "固件传输暂停";
      case OtaUpgradeStatus.transferFailed:
        return "固件传输失败";
      case OtaUpgradeStatus.transferSuccess:
        return "固件传输成功";
      case OtaUpgradeStatus.waitingUserAction:
        return "等待用户操作";
      case OtaUpgradeStatus.upgrading:
        return "升级中";
      case OtaUpgradeStatus.upgradeSuccess:
        return "升级成功";
      case OtaUpgradeStatus.upgradeFailed:
        return "升级失败";
      case OtaUpgradeStatus.cancelled:
        return "已取消";
    }
  }
}
